package inventory.inventory.dataObjects
{
	import common.utils.DateManager;
	
	import mx.collections.ArrayCollection;
	[Bindable]
	public class InventoryDO
	{
		public var INTERNAL_LOCATION_INV:int = 0;
		public var WAREHOUSE:String = "";
		public var LOCATION:String = "";
		public var ITEM:String = "";
		public var ITEM_DESC:String = "";
		public var COMPANY:String = "";
		public var PERMANENT:String = "";
		public var ATTRIBUTE_NUM:int = 0;
		public var ON_HAND_QTY:int = 0;
		public var IN_TRANSIT_QTY:int = 0;
		public var ALLOCATED_QTY:int = 0;
		public var QUANTITY_UM:String = "";
		public var INVENTORY_STS:String = "";
		public var AGING_DATE:String = DateManager.GetTodayString();
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();
		public var LPN:String = "";
		public var PARENT_LPN:String = "";
		public var ATTRIBUTE1:String;
		public var ATTRIBUTE2:String;
		public var ATTRIBUTE3:String;
		public var ATTRIBUTE4:String;
		public var ATTRIBUTE5:String = "";
		public var ATTRIBUTE6:String = "";
		public var ATTRIBUTE7:String = "";
		public var ATTRIBUTE8:String = "";
		public var ZONE:String = "";

		public function InventoryDO(){
		}

		public function Init(xmlObj:XML):void
		{
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}
		}
		
		public function ToXML():XML{
			var xmlObj:XML =
				<LOCATION_INVENTORY>
					<INTERNAL_LOCATION_INV>{INTERNAL_LOCATION_INV}</INTERNAL_LOCATION_INV>
					<WAREHOUSE>{WAREHOUSE}</WAREHOUSE>
					<LOCATION>{LOCATION}</LOCATION>
					<ITEM>{ITEM}</ITEM>
					<ITEM_DESC>{ITEM_DESC}</ITEM_DESC>
					<COMPANY>{COMPANY}</COMPANY>
					<PERMANENT>{PERMANENT}</PERMANENT>
					<ATTRIBUTE_NUM>{ATTRIBUTE_NUM}</ATTRIBUTE_NUM>
					<ON_HAND_QTY>{ON_HAND_QTY}</ON_HAND_QTY>
					<IN_TRANSIT_QTY>{IN_TRANSIT_QTY}</IN_TRANSIT_QTY>
					<ALLOCATED_QTY>{ALLOCATED_QTY}</ALLOCATED_QTY>
					<QUANTITY_UM>{QUANTITY_UM}</QUANTITY_UM>
					<INVENTORY_STS>{INVENTORY_STS}</INVENTORY_STS>
					<AGING_DATE>{AGING_DATE}</AGING_DATE>
					<USER_STAMP>{USER_STAMP}</USER_STAMP>
					<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
					<LPN>{LPN}</LPN>
					<PARENT_LPN>{PARENT_LPN}</PARENT_LPN>
					<ATTRIBUTE1>{ATTRIBUTE1}</ATTRIBUTE1>
					<ATTRIBUTE2>{ATTRIBUTE2}</ATTRIBUTE2>
					<ATTRIBUTE3>{ATTRIBUTE3}</ATTRIBUTE3>
					<ATTRIBUTE4>{ATTRIBUTE4}</ATTRIBUTE4>
					<ATTRIBUTE5>{ATTRIBUTE5}</ATTRIBUTE5>
					<ATTRIBUTE6>{ATTRIBUTE6}</ATTRIBUTE6>
					<ATTRIBUTE7>{ATTRIBUTE7}</ATTRIBUTE7>
					<ATTRIBUTE8>{ATTRIBUTE8}</ATTRIBUTE8>
				</LOCATION_INVENTORY>;
			return xmlObj;
		}
		

		public static function getInventories(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var invDtl:InventoryDO = new InventoryDO();
				invDtl.Init(xml);
				ac.addItem(invDtl);
			}
			return ac;
		}		
	}
}